Back to course home
0% completed
Vote For New Content
Appendix
Contact Us
Longest Common Subsequence
Problem Statement
Given two strings 's1' and 's2', find the length of the longest subsequence which is common in both the strings.
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
Example 1:
Input: s1 = "abdca"
s2 = "cbda"
Output: 3
Explanation: The longest common subsequence is "bda".
Example 2:
Input: s1 = "passport"
s2 = "ppsspt"
Output: 5
Explanation: The longest common subsequence is "psspt".
Constraints:
- 1 <= s1.length, s2.length <= 1000`
s1ands2consist of only lowercase English characters.
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Longest Common Substring
Solution: Longest Common Subsequence
Mark as Completed
On this page
Problem Statement
Try it yourself